<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('道路基本信息列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>


                        <li>
                            <label>路段：</label>
                            <select name="chroadName" id="chroadName"
                                    th:with="type=${roadInformationList}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.chroadName}"
                                        th:value="${dict.chroadName}"></option>
                            </select>
                            <select name="roadName" id="roadName"></select>
                        </li>

                        <li>
                            <label>路面结构：</label>
                            <select name="stru"
                                    th:with="type=${@dict.getType('road-stru')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                        </li>

                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="road:information:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-primary single disabled" onclick="$.operate.edit()"
               shiro:hasPermission="road:information:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()"
               shiro:hasPermission="road:information:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="road:information:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" data-show-print="true" ></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: bootstrap-table-print-js"/>
<th:block th:include="include :: bootstrap-table-export-js"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('road:information:edit')}]];
    var removeFlag = [[${@permission.hasPermi('road:information:remove')}]];
    var struDatas = [[${@dict.getType('road-stru')}]];
    var prefix = ctx + "road/information";

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "道路基本信息",
            showExport: true,
            columns: [{
                printIgnore:true,
                checkbox: true
            },
                {
                    field: 'id',
                    title: '主键',
                    printIgnore:true,
                    visible: false
                },
                {
                    field: 'firstRoadName',
                    title: '路线Py',
                    printIgnore:true,
                    visible: false
                },
                {
                    field: 'chroadName',
                    title: '路线'
                },
                {
                    field: 'companyName',
                    title: '公司Py',
                    printIgnore:true,
                    visible: false
                },
                {
                    field: 'company',
                    title: '公司'
                },
                {
                    field: 'companySort',
                    title: '公司排序',
                    printIgnore:true,
                    visible: false
                },
                {
                    field: 'roadName',
                    title: '路段'
                },
                {
                    field: 'sectionId',
                    title: '路线编号'
                },
                {
                    field: 'startName',
                    title: '启点'
                },
                {
                    field: 'endName',
                    title: '终点'
                },
                {
                    field: 'location',
                    title: '路线地区',
                    printIgnore:true,
                    visible: false
                },
                {
                    field: 'startpilenumber',
                    title: '起点桩号'
                },
                {
                    field: 'endpilenumber',
                    title: '终点桩号'
                },
                {
                    field: 'sort',
                    title: '排序',
                    printIgnore:true,
                    visible: false
                },
                {
                    field: 'starttime',
                    title: '开始年',
                    printIgnore:true,
                    visible: false
                },
                {
                    field: 'stru',
                    title: '路面结构',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(struDatas, value);
                    },
                    printFormatter: function (value, row, index) {
                        return $.table.selectDictLabel(struDatas, value);
                    }
                },
                {
                    field: 'opentime',
                    title: '通车日期',
                    printIgnore:true,
                    visible: false
                },
                {
                    field: 'suai',
                    title: '衰变系数',
                    printIgnore:true,
                    visible: false
                },
                {
                    field: 'createDate',
                    title: '创建时间',
                    printIgnore:true,
                    visible: false
                },
                {
                    field: 'updateDate',
                    title: '更新时间',
                    printIgnore:true,
                    visible: false
                },
                {
                    field: 'remarks',
                    title: '备注信息',
                    printIgnore:true,
                    visible: false
                },
                {
                    title: '操作',
                    align: 'center',
                    printIgnore:true,
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    $("#chroadName").on("change", function () {
        $.ajax({
                url: prefix + '/selectRoadInformationRoadNameByChroad/' + $("#chroadName").val(),
                type: 'get',
                success: function (result) {
                    var options = '<option value = "" >' + "请选择具体路段名称" + '</option>';
                    $.each(result,function (index,item) {
                        options += '<option value = "'+ item.roadName + '" >' + item.roadName + '</option>';
                    })
                    $("#roadName").html(options);
                }
            }
        );
    })
</script>
</body>
</html>
